<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			var getName=document.getElementById("city");
			
			//var	resultStr1=getName.replace(/[ ]/g,"");    //去掉空格
			//var resultStr2=getName.replace(/[\r\n]/g,"");//去掉回车换行
			window.onload=function(){
		var oUl=document.getElementById("city");
        console.log(oUl.children.length);
			}
        
		</script>
	</head>
	<body>
		<ul id="city">
			<li id="bj">北京</li>
			<li id="sh">上海</button></li>
			<li id="dj">东京</button></li>
			<li id="se">首尔</button></li>
		</ul>
		
		<br><br>
		
		<ul id="game">
			<li id="rl">红警</li>
			<li id="sk">实况</li>
			<li id="jp">极品飞车</li>
			<li id="ms">魔兽</li>
		</ul>
	</body>
</html>
